﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Diagnostics;
using Dcm.ConfigMapAttributes;

namespace Dcm.Tests.ConfigMapAttributes
{
    [TestClass]
    public class HostnameRegExTests
    {
        const string ConfigMapAttributeName = "hostnameRegEx";

        [TestInitialize()]
        public void Startup()
        {
            Debug.WriteLine(HostnameRegEx.GetHostname());
        }

        [TestMethod] // Tests HostName and executablePath location (example: "B0000AJFI3JF22" and "C:\MyApp\Bin")
        [DependencyOn(typeof(Environment))]
        [DependencyOn("app.config")]
        [DependencyOn(typeof(ExecutablePath))] // varies between .../bin/debug and .../TestResults/* and does not match via a wildcard
        public void TestHostNameRegExecutablePathSetViaAppConfig()
        {
            const string expected = "hostNameRegExExecutablePathValue1";
            string actual = DynamicConfigurationManager.DynamicConfigurationManager.AppSettings["hostNameRegExExecutablePathKey1"];
            if (expected != actual)
            {
                
                var path = ExecutablePath.GetExecutablePath();
                Debug.WriteLine("path was " + path);
                Debug.WriteLine(DynamicConfigurationManager.DynamicConfigurationManager.Log);
                Assert.Inconclusive(Utilities.UnreliableTest);
            }

            Assert.AreEqual(expected, actual);
        }
    }
}
